<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="format-detection" content="telephone=no"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="icon" href="/forest-blog/images/icons/favicon-16x16.png?v=2.8.0" type="image/png" sizes="16x16"><link rel="icon" href="/forest-blog/images/icons/favicon-32x32.png?v=2.8.0" type="image/png" sizes="32x32"><meta property="og:type" content="website">
<meta property="og:title" content="最佳嫌疑兔的博客">
<meta property="og:url" content="https://gitee.com/best-suspect/index.html">
<meta property="og:site_name" content="最佳嫌疑兔的博客">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="Forest Soong">
<meta name="twitter:card" content="summary"><title>最佳嫌疑兔的博客</title><link ref="canonical" href="https://gitee.com/best-suspect/index.html"><link rel="dns-prefetch" href="https://cdn.jsdelivr.net"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.12.1/css/all.min.css" type="text/css"><link rel="stylesheet" href="/forest-blog/css/index.css?v=2.8.0"><link rel="stylesheet" href="css/custom.css"><script>var Stun = window.Stun || {};
var CONFIG = {
  root: '/forest-blog/',
  algolia: undefined,
  assistSearch: undefined,
  fontIcon: {"prompt":{"success":"fas fa-check-circle","info":"fas fa-arrow-circle-right","warning":"fas fa-exclamation-circle","error":"fas fa-times-circle"},"copyBtn":"fas fa-copy"},
  sidebar: {"offsetTop":"150px","tocMaxDepth":6},
  header: {"enable":true,"showOnPost":true,"scrollDownIcon":true},
  postWidget: {"endText":true},
  nightMode: {"enable":true},
  back2top: {"enable":true},
  codeblock: {"style":"default","highlight":"dark","wordWrap":true},
  reward: false,
  fancybox: false,
  zoomImage: {"gapAside":"20px"},
  galleryWaterfall: undefined,
  lazyload: false,
  pjax: undefined,
  externalLink: {"icon":{"enable":true,"name":"fas fa-external-link-alt"}},
  shortcuts: undefined,
  prompt: {"copyButton":"Copy","copySuccess":"Copy Success","copyError":"Copy Error"},
  sourcePath: {"js":"js","css":"css","images":"images"},
};

window.CONFIG = CONFIG;</script><meta name="generator" content="Hexo 6.3.0"></head><body><div class="container" id="container"><header class="header" id="header"><div class="header-inner"><nav class="header-nav header-nav--fixed"><div class="header-nav-inner"><div class="header-nav-menubtn"><i class="fas fa-bars"></i></div><div class="header-nav-menu"><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/"><span class="header-nav-menu-item__icon"><i class="fas fa-home"></i></span><span class="header-nav-menu-item__text">Home</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/archives/"><span class="header-nav-menu-item__icon"><i class="fas fa-folder-open"></i></span><span class="header-nav-menu-item__text">Archives</span></a></div></div><div class="header-nav-mode"><div class="mode"><div class="mode-track"><span class="mode-track-moon"></span><span class="mode-track-sun"></span></div><div class="mode-thumb"></div></div></div></div></nav><div class="header-banner"><div class="header-banner-info"><div class="header-banner-info__title">最佳嫌疑兔的个人博客</div></div><div class="header-banner-arrow"><div class="header-banner-arrow__icon"><i class="fas fa-angle-down"></i></div></div></div></div></header><main class="main" id="main"><div class="main-inner"><div class="content-wrap" id="content-wrap"><div class="content content-home" id="content"><section class="postlist"><article class="postlist-item post"><header class="post-header"><h1 class="post-title"><a class="post-title__link" href="/forest-blog/2022/12/12/first-blog/">npm install XXX安装路径文件夹权限问题（npm ERR! The operation was rejected by your operating system.errno -4080）</a></h1><div class="post-meta"><span class="post-meta-item post-meta-item--createtime"><span class="post-meta-item__icon"><i class="far fa-calendar-plus"></i></span><span class="post-meta-item__info">Created</span><span class="post-meta-item__value">2022-12-12</span></span><span class="post-meta-item post-meta-item--updatetime"><span class="post-meta-item__icon"><i class="far fa-calendar-check"></i></span><span class="post-meta-item__info">Updated</span><span class="post-meta-item__value">2022-12-12</span></span></div></header><div class="post-body"><div class="post-excerpt"><p><strong>如果着急解决此问题可直接参考“问题解决”部分的解决办法（希望有用~）</strong><br>初次安装配置nodejs完成后，准备安装个常用的express模块测试一下，使用npm install XXXX 命令进行全局安装出现报错，最后翻找各种各样的报错信息解决方案还是没有解决，最终通过结合自己之前的操作以及报错信息的说明尝试更改目录文件夹的权限，最终问题得以解决</p>
<h2 id="问题分析："><a href="#问题分析：" class="headerlink" title="问题分析："></a>问题分析：</h2><p>无论是使用VSCode或是在黑窗口（win+R 键入 cmd）下用npm安装一些东东（XXXX）：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install koa					 这里安装的是koa</span><br></pre></td></tr></table></figure>
<p>运行结果如下：一大堆报错。。。【如果你也是看见 ERROR 就头疼那么接下来你要做的就是<strong>静下心来，好好阅读报错信息，这个真的很重要！！！</strong>】</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">npm ERR! code EPERM</span><br><span class="line">npm ERR! syscall open</span><br><span class="line">npm ERR! path E:\Node_js\nodejs\node_cache\_locks\staging-945e94f7a493b189.lock</span><br><span class="line">npm ERR! errno -4048</span><br><span class="line">npm ERR! Error: EPERM: operation not permitted, open &#x27;E:\Node_js\nodejs\node_cache\_locks\staging-945e94f7a493b189.lock&#x27;</span><br><span class="line">npm ERR!  [Error: EPERM: operation not permitted, open &#x27;E:\Node_js\nodejs\node_cache\_locks\staging-945e94f7a493b189.lock&#x27;] &#123;</span><br><span class="line">npm ERR!   errno: -4048,</span><br><span class="line">npm ERR!   code: &#x27;EPERM&#x27;,</span><br><span class="line">npm ERR!   syscall: &#x27;open&#x27;,</span><br><span class="line">npm ERR!   path: &#x27;E:\\Node_js\\nodejs\\node_cache\\_locks\\staging-945e94f7a493b189.lock&#x27;</span><br><span class="line">npm ERR! &#125;</span><br><span class="line">npm ERR!</span><br><span class="line">npm ERR! The operation was rejected by your operating system.</span><br><span class="line">npm ERR! It&#x27;s possible that the file was already in use (by a text editor or antivirus),</span><br><span class="line">npm ERR! or that you lack permissions to access it.</span><br><span class="line">npm ERR!</span><br><span class="line">npm ERR! If you believe this might be a permissions issue, please double-check the</span><br><span class="line">npm ERR! permissions of the file and its containing directories, or try running</span><br><span class="line">npm ERR! the command again as root/Administrator.</span><br></pre></td></tr></table></figure>
<p>耐心读完报错信息后你会发现，有用的或者说看得懂的也就只有最后的那几行，这不就简单了，有道词典【或者什么百度翻译的都可以】里面粘贴进去看看什么意思：<br>（同时说明一下 npm ERR！只是告诉你这一行是关于npm的报错信息而已，不用去纠结哈！）</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm ERR! The operation was rejected by your operating system.</span><br></pre></td></tr></table></figure>

<blockquote>
<p>翻译说：你的操作系统拒绝了这个操作。</p>
</blockquote>
<p>【好奇是什么操作？】</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm ERR! It&#x27;s possible that the file was already in use (by a text editor or antivirus),</span><br><span class="line">npm ERR! or that you lack permissions to access it.</span><br></pre></td></tr></table></figure>

<blockquote>
<p>翻译说：有可能该文件已经在使用(通过文本编辑器或反病毒程序)，或者您缺乏访问权限。</p>
</blockquote>
<p>好的，看到这里可能就慌了，特别是这个‘反病毒程序’，然后就开始怀疑自己的电脑是不是中病毒了，然后就打开某60杀毒软件开始扫描电脑。。。如果真有像这样操作的同志们完全可以大胆的在下面评论“就是我！”【理不直，气必须要壮！】</p>
<p>反观这句话，它的意思不就是你有可能已经把你这个文件或者程序打开了但是你不晓得，又或者是你自己没有权限去操作你的文件或者程序然后你还是不晓得。既然如此，我好好看了一下我的杀毒软件和编辑器好像也没有对它干嘛，于是我就猜测可能是因为‘权限问题’导致了访问某个文件或者程序的时候被制止了，于是我将目光投向我的两个新建的文件夹。【顿时脑子中闪过一道光】那俩新建的文件夹里面没有文件，而我就是要把那两个文件夹设置为我的新的存放代码的地方，似乎我新建的文件夹权限不够它来访问的喔！</p>
<p>确定了目标，接下来就是行动了。<br>等等，还有三行English，那就是顺便也翻译一下吧：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">npm ERR! If you believe this might be a permissions issue, please double-check the</span><br><span class="line">npm ERR! permissions of the file and its containing directories, or try running</span><br><span class="line">npm ERR! the command again as root/Administrator.</span><br></pre></td></tr></table></figure>

<blockquote>
<p>翻译说：如果您认为这可能是一个权限问题，请再次检查文件及其包含目录的权限，或以root&#x2F;Administrator用户再次执行命令尝试运行。</p>
</blockquote>
<p>行吧，看完这句话基本上也更加确定了就是文件夹权限的问题，然后它开始教你做事了…【它都开始教你做事了，你说你要它教吗？当然要！(*￣︶￣)】他说你错了就是错了，他让你怎么改你就怎么改，端正态度！【是不是像极了你的领导和你】</p>
<p>下面请看问题解决部分…</p>
<h2 id="问题解决："><a href="#问题解决：" class="headerlink" title="问题解决："></a>问题解决：</h2><p>更改文件夹权限：<br>找到对应的文件夹，我这里因为安装nodejs时更改过npm的安装路径为文件夹“node_cache”以及npm的安装地址文件夹“node_global”分别更改这两个文件夹的Users权限<br><img src="https://img-blog.csdnimg.cn/deaf6fa6759e43a39f228fb0ba9c2521.png" alt="在这里插入图片描述"></p>
<p>右键 “属性” -&gt; “安全” -&gt; “编辑”<br><strong>（注意这里的编辑要在系统权限下才有用！（也就是前面要有个小盾牌）！）</strong><br><img src="https://img-blog.csdnimg.cn/5ed47f840f6f4b9196f00c8d8ea93297.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Njc5NDM4NQ==,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>把Users的权限设置为<strong>全部允许</strong>（理论上在完全控制后面打勾就行）-&gt;“应用” -&gt;“确定”<br><img src="https://img-blog.csdnimg.cn/5aa7cdb783a64daba40f9da96c363bd0.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Njc5NDM4NQ==,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>将刚才执行的窗口（cmd窗口 和 VSCode）关闭后再打开<br>再次执行刚才的npm安装命令安装刚才安装失败的东西，这里我安装的是koa</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install koa</span><br></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/9b1e978e2d1c47c6ab0f75a54d362f33.png" alt="安装成功！问题解决"><br>成功！！</p>
<h2 id="反思"><a href="#反思" class="headerlink" title="反思"></a>反思</h2><ol>
<li>遇到通篇的报错不要慌看看English的内容，往往最容易的解决的问题总是最容易被忽略</li>
<li>独立思考能力：敢于尝试独立去思考一些错误问题的原因</li>
<li>总结因果，理清问题解决的思路，不是保证不再报错 而是要保证下次错误时知道怎么解决</li>
</ol>
<h2 id="结语"><a href="#结语" class="headerlink" title="结语"></a>结语</h2><p>当然，以上是基于自己所遇到的问题去寻找到的一种解决办法，可能遇到的问题和我的有所出入或是相似而不同，因为在解决问题的时候并没有搜索到可以直接解决我的问题的方法所以就写下了这篇文章，希望对和我有同样问题的同志们提供些许帮助。</p>
<p>这也是我所写的第一篇文章，如果有什么地方写的不对的有误的欢迎各位大佬在评论区交流。<br><strong>如果对你有帮助的话不妨点个赞再走噢！</strong></p>
</div></div></article></section><nav class="paginator"><div class="paginator-inner"><span class="page-number current">1</span></div></nav></div></div><div class="sidebar-wrap" id="sidebar-wrap"><aside class="sidebar" id="sidebar"><section class="sidebar-toc hide"></section><!-- ov = overview--><section class="sidebar-ov"><div class="sidebar-ov-author"><div class="sidebar-ov-author__avatar"><img class="sidebar-ov-author__avatar_img" src="https://foruda.gitee.com/avatar/1676882208193630042/9070911_best-suspect_1676882208.png!avatar200" alt="avatar"></div><p class="sidebar-ov-author__text">最佳嫌疑兔</p></div><div class="sidebar-ov-state"><a class="sidebar-ov-state-item sidebar-ov-state-item--posts" href="/archives/"><div class="sidebar-ov-state-item__count">1</div><div class="sidebar-ov-state-item__name">Archives</div></a></div><div class="sidebar-ov-cc"><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en" target="_blank" rel="noopener" data-popover="Creative Commons" data-popover-pos="up"><img src="/forest-blog/images/cc-by-nc-sa.svg"></a></div></section></aside></div><div class="clearfix"></div></div></main><footer class="footer" id="footer"><div class="footer-inner"><div><span>Copyright © 2023</span><span class="footer__icon"><i class="fas fa-heart"></i></span><span>Forest Soong</span></div></div></footer><div class="loading-bar" id="loading-bar"><div class="loading-bar__progress"></div></div><div class="back2top" id="back2top"><span class="back2top__icon"><i class="fas fa-rocket"></i></span></div></div><script src="https://cdn.jsdelivr.net/npm/jquery@v3.4.1/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.ui.min.js"></script><script src="https://cdn.jsdelivr.net/npm/ribbon.js@latest/dist/ribbon.min.js" size="120" alpha="0.6" zIndex="-1"></script><script src="https://cdn.jsdelivr.net/npm/canvas-nest.js@1.0.1/dist/canvas-nest.min.js" color="0,0,0" opacity="0.6" count="99" zIndex="-1"></script><script src="/forest-blog/js/utils.js?v=2.8.0"></script><script src="/forest-blog/js/stun-boot.js?v=2.8.0"></script><script src="/forest-blog/js/scroll.js?v=2.8.0"></script><script src="/forest-blog/js/header.js?v=2.8.0"></script><script src="/forest-blog/js/sidebar.js?v=2.8.0"></script></body></html>